package com.android.Lmaps;

import com.google.android.gms.maps.model.LatLng;

import android.text.format.Time;



public class phongtro{
	
	private String id;//auto set
	private String address;//insert by person
	private Double lat,lon,price;//map set

	private String description;//insert by person
	private int day,month,year,hour,minute;//auto set
	private String contact;//insert by person
	private Boolean personShare;//auto set

	
	public phongtro(String address, Double lat, Double lon, Double price,
			String description, String contact, Boolean personShare) {
		super();
		//id
		this.address = address;
		this.lat = lat;
		this.lon = lon;
		this.price = price;
		this.description = description;
		// minute, hour, day, month, year
		this.contact = contact;
		this.personShare = personShare;
		//--------------- auto-------------
		
		
		//make time
		Time now = new Time();
		now.setToNow();
		this.minute = now.minute;
		this.hour = now.hour;
		this.day =now.monthDay;
		this.month =now.month;
		this.year = now.year;
		//make id
		this.id = ""+this.hour+this.minute+this.day+this.month+this.year;
		
	}
//	public phongtro(Parcel parcel) {
//		super();
//		readFromParcel(parcel);
//		// TODO Auto-generated constructor stub
//	}
	public phongtro() {
		super();
		// TODO Auto-generated constructor stub
	}
	public String getId() {
		return id;
	}
	public void setId() {
		//make id
		
		this.id = ""+this.hour+this.minute+this.day+this.month+this.year;
		
	}
	public void setId(String id) {
		this.id=id;
	}
	public String getAddress() {
		return address;
	}
	public void setAddress(String address) {
		this.address = address;
	}
	public Double getLat() {
		return lat;
	}
	public void setLat(Double lat) {
		this.lat = lat;
	}
	public Double getLon() {
		return lon;
	}
	public void setLon(Double lon) {
		this.lon = lon;
	}
	public Double getPrice() {
		return price;
	}
	public void setPrice(Double price) {
		this.price = price;
	}
	public String getDescription() {
		return description;
	}
	public void setDescription(String description) {
		this.description = description;
	}
	public int getDay() {
		return day;
	}
	public void setDay(int day) {
		this.day=day;
	}
	public int getMonth() {
		return month;
	}
	public void setMonth(int month) {
		this.month=month;
	}
	public int getYear() {
		return year;
	}
	public void setYear(int year) {
		this.year=year;
	}
	public int getHour() {
		return hour;
	}
	public void setHour(int hour) {
		this.hour=hour;
	}
	public int getMinute() {
		return minute;
	}
	public void setMinute(int minute) {
		this.minute=minute;
	}
	public void setTime()
	{
		Time now = new Time();
		now.setToNow();
		this.minute = now.minute;
		this.hour = now.hour;
		this.day =now.monthDay;
		this.month =now.month;
		this.year = now.year;
	}
	public String getContact() {
		return contact;
	}
	public void setContact(String contact) {
		this.contact = contact;
	}
	public Boolean getPersonShare() {
		return personShare;
	}
	public void setPersonShare(Boolean personShare) {
		this.personShare = personShare;
	}
	@Override
	public int hashCode() {
		final int prime = 31;
		int result = 1;
		result = prime * result + ((id == null) ? 0 : id.hashCode());
		return result;
	}
	@Override
	public boolean equals(Object obj) {
		if (this == obj)
			return true;
		if (obj == null)
			return false;
		if (getClass() != obj.getClass())
			return false;
		phongtro other = (phongtro) obj;
		if (id == null) {
			if (other.id != null)
				return false;
		} else if (!id.equals(other.id))
			return false;
		return true;
	}
	@Override
	public String toString() {
		return " address: " + address + 
				"\n price:" + price	+ 
				"\n description:" + description + 
				"\n date:" + minute + ":" + hour +"-=-"+day+"/"+month+"/"+year+
				"\n contact:" + contact;
	}
	public void editPhongtro(phongtro pt)
	{
		//id
		this.address = pt.getAddress();
		this.lat = pt.getLat();
		this.lon = pt.getLon();
		this.price = pt.getPrice();
		this.description = pt.getDescription();
		// minute, hour, day, month, year
		this.contact = pt.getContact();
		this.personShare = pt.getPersonShare();
		//--------------- auto-------------
		//make time
		Time now = new Time();
		now.setToNow();
		this.minute = now.minute;
		this.hour = now.hour;
		this.day =now.monthDay;
		this.month =now.month;
		this.year = now.year;
	}
	
	public void findByLocation(LatLng location) {
	
	}
	
//	private void readFromParcel(Parcel in) {
////		mystringlist.add(getId());//0
////		mystringlist.add(getAddress());//1
////		mystringlist.add(getDescription());//2
////		mystringlist.add(getContact());//3
////		mystringlist.add(getPersonShare());//4
//		ArrayList<String> mystringlist = new ArrayList<String>();
//		in.readStringList(mystringlist);
//		int[] myintlist = new int[7];
//		in.readIntArray(myintlist);
//		double[] mydoublelist= new double[3];
//		in.readDoubleArray(mydoublelist);
//		
//		this.setId(mystringlist.get(0));
//		this.setAddress(mystringlist.get(1));
//		this.setDescription(mystringlist.get(2));
//		this.setContact(mystringlist.get(3));
//		this.setPersonShare(mystringlist.get(4));
////		int[] myintlist = new int[7];
////		myintlist[0]=getPrice();//0
////		myintlist[1]=getDay();//1
////		myintlist[2]=getMonth();//2
////		myintlist[3]=getYear();//3
////		myintlist[4]=getHour();//4
////		myintlist[5]=getMinute();//5
//		this.setPrice(myintlist[0]);
//		this.setDay(myintlist[1]);
//		this.setMonth(myintlist[2]);
//		this.setYear(myintlist[3]);
//		this.setHour(myintlist[4]);
//		this.setMinute(myintlist[5]);
////		double[] mydoublelist= new double[3];
////		mydoublelist[0]=getLat();//0
////		mydoublelist[1]=getLon();//1
//		this.setLat(mydoublelist[0]);
//		this.setLon(mydoublelist[1]);
//  }
////    @Override
////    public int describeContents() {
////        return 0;  //To change body of implemented methods use File | Settings | File Templates.
////    }
////
//	@Override
//	public int describeContents() {
//		// TODO Auto-generated method stub
//		return 0;
//	}
////    @Override
////    public void writeToParcel(Parcel parcel, int flags) {
////        parcel.writeString(getId());
////        parcel.writeInt(getValue());
////    }
//	@Override
//	public void writeToParcel(Parcel dest, int flags) {
//		// TODO Auto-generated method stub
//		ArrayList<String> mystringlist=new ArrayList<String>();
//		mystringlist.add(getId());//0
//		mystringlist.add(getAddress());//1
//		mystringlist.add(getDescription());//2
//		mystringlist.add(getContact());//3
//		mystringlist.add(getPersonShare());//4
//		
//		int[] myintlist = new int[7];
//		myintlist[0]=getPrice();//0
//		myintlist[1]=getDay();//1
//		myintlist[2]=getMonth();//2
//		myintlist[3]=getYear();//3
//		myintlist[4]=getHour();//4
//		myintlist[5]=getMinute();//5
//		
//		double[] mydoublelist= new double[3];
//		mydoublelist[0]=getLat();//0
//		mydoublelist[1]=getLon();//1
//		
//		dest.writeStringList(mystringlist);
//		dest.writeIntArray(myintlist);//(myintlist);
//		dest.writeDoubleArray(mydoublelist);
//	}
////    public static final Creator<customObject> CREATOR =  new Creator<customObject>() {
////        @Override
////        public customObject createFromParcel(Parcel parcel) {
////            return new customObject(parcel);
////        }
////
////        @Override
////        public customObject[] newArray(int i) {
////           return new customObject[i];
////        }
////    } ;
//
//	 public static final Creator<phongtro> CREATOR =  new Creator<phongtro>() {
//       @Override
//       public phongtro createFromParcel(Parcel parcel) {
//           return new phongtro(parcel);
//       }
//
//       @Override
//       public phongtro[] newArray(int i) {
//          return new phongtro[i];
//       }
//   } ;
	
}
